# Maintainer: Alx Sa <cmyk.student@gmail.com>

_realname=libilbm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.1.r68.g170c269
pkgrel=2
pkgdesc="Parser library for the ILBM: IFF Interleaved BitMap format (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/svanderburg/libilbm"
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-libiff")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             'help2man'
             'git')
_appcommit='170c269bce23423f1163545ed9344482b2cf4487'
source=("${_realname}"::"git+https://github.com/svanderburg/libilbm.git#commit=$_appcommit"
        0001-libilbm-fix-shared-library.patch)
sha256sums=('SKIP'
            'f5cf5b89fa9afab573ede7a542046f93b87309811b13f51d5b9c095b953ea7bf')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "0.1.r%s.g%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}"/${_realname}
  git apply "${srcdir}/0001-libilbm-fix-shared-library.patch"

  ./bootstrap
}

build() {
  cd "${srcdir}"/${_realname}

  ./configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}" \
    --target="${MINGW_CHOST}" \
    --enable-static \
    --enable-shared

  make -j 1
}

package() {
  cd "${srcdir}"/${_realname}
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
